package com.yupi.usercenter.common;

/**
 * ClassName: ResultUtils
 * Package: com.yupi.usercenter.common
 * Description:返回结果工具类
 *
 * @Author:
 * @Create: 2024/3/16 - 22:26
 * @Version: v1.0
 */
public class ResultUtils {

    /**
     * 成功
     * @param data
     * @return
     * @param <T>
     */
    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>(200, data, "ok");
    }


    /**
     * 失败
     * @param errorCode
     * @return
     */
    public static BaseResponse error(ErrorCode errorCode) {
        return new BaseResponse(errorCode);
    }

    /**
     * 失败
     * @param errorCode
     * @return
     */
    public static BaseResponse error(ErrorCode errorCode, String description) {
        return new BaseResponse(errorCode, description);
    }

    /**
     * 失败
     * @param errorCode
     * @return
     */
    public static BaseResponse error(ErrorCode errorCode, String message, String description) {
        return new BaseResponse(errorCode, message, description);
    }


    /**
     * 失败
     * @return
     */
    public static BaseResponse error(int code, String message, String description) {
        return new BaseResponse(code, message, description);
    }

}
